﻿
@{
    Layout = "~/Views/Shared/_LayoutBlank.cshtml";
}

<style>
    body {
        /*margin-top: 1.5rem;*/
         margin-top: 1.2rem;
        margin-bottom: 0.55rem;
    }

    #divTopTitleBar {
        position: fixed;
        left: 0rem;
        right: 0rem;
        /*top: 1rem;*/
         top:0.7rem;
        height: 0.4rem;
        background-color: white;
    }

    .imgItem {
        max-height: 0.75rem;
        max-width: 0.9rem;
        vertical-align: middle;
    }

    .divItemDetailTitle {
        height: 0.35rem;
        line-height: 0.35rem;
        text-align: center;
        font-size: 0.16rem;
        font-weight: bold;
        color: #FFFFFF;
    }


    .divBorder {
        border: 1px solid #CCC;
        height: 0.3rem;
        font-size: 0.15rem;
        line-height: 0.3rem;
    }

    #divFooter {
        position: fixed;
        bottom: 0px;
        left: 0px;
        right: 0px;
        height: 0.4rem;
        font-size: 0.14rem;
        text-align: center;
        background-color: #F5F5F5;
    }
</style>

<script>

    //当前页
    var _currentPage = 1;
    var _totalPage = 1;

    $(document).ready(function () {
        loadData();
    });

    function loadData(targetPage) {
        if (targetPage > _totalPage)
            return;

        var loadLayerIndex = layer.open({
            type: 2,
            shadeClose: false,
            content: '请稍候...'
        });

        var args = new Object();
        args.Page = targetPage || 1;
        args.PageSize = 10;

        $.ajax({
            url: "/Api/OneDollarBuying/GetLuckyList/@ViewBag.Domain.Id",
            type: "POST",
            dataType: "json",
            data: JSON.stringify(args),
            success: function (data, status, jqXHR) {
                // alert(data);

                layer.close(loadLayerIndex);
                if (data.Success) {
                    var resultObj = data.Data;

                    //alert(JSON.stringify(resultObj));
                    var gettpl = document.getElementById('commodityListTemplate').innerHTML;
                    laytpl(gettpl).render(resultObj.ItemList, function (html) {
                        document.getElementById('divCommodityContainer').innerHTML += html;
                    });

                    _currentPage = resultObj.Page;
                    _totalPage = resultObj.TotalPage;
                    if (_currentPage >= _totalPage) {
                        $("#divPagingContainer").html("没有更多了");
                    }

                } else {
                    layerAlert(data.Message);
                }
            },
            error: function (xmlHttpRequest) {
                layer.close(loadLayerIndex);
                // alert("Error: " + xmlHttpRequest.status);
            }
        });
    }

    function commodityDetail(commodityId,saleId) {

        window.location.href = '/Campaign/OneDollarBuyingCommodityDetail/@ViewBag.Domain.Id?commodityId=' + commodityId + "&saleId=" + saleId;
    }

    function deposit() {
        window.location.href = '/Pay/Deposit/@ViewBag.Domain.Id';
    }

</script>

<script id="commodityListTemplate" type="text/html">

    {{# for(var i = 0, len = d.length; i < len; i++){ }}

    <div onclick="commodityDetail('{{ d[i].CommodityId }}','{{ d[i].Id }}')">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td style="width:1rem;" valign="top">
                    <img src="{{ d[i].ImageUrl }}" class="imgItem">
                </td>
                <td valign="top">
                    <div style="font-size:0.15rem;font-weight:bold">{{ d[i].CommodityName }}</div>
                    <div style="margin-top:0.05rem; font-size:0.12rem;color:#555555;">
                        <div style="margin-top:0.05rem;">期号：{{ d[i].PeriodNumber }}</div>

                        {{# if(d[i].LuckyPartNumber != null && d[i].LuckyPartNumber != ""){ }}
                        <div style="margin-top:0.05rem;">幸运号码：<span style="color:red">{{ d[i].LuckyPartNumber }}</span></div>
                        <div style="margin-top:0.05rem;">获得者：<span style="color:#2659FF">{{ d[i].LuckyMemberNickName }}</span></div>
                        <div style="margin-top:0.05rem;">揭晓时间：{{ d[i].DrawTime }}</div>
                        {{# }else{ }}
                        <div style="margin-top:0.05rem;"><span style="color:red">马上揭晓</span></div>
                        {{# } }}

                    </div>

                </td>
            </tr>
        </table>
    </div>

    <div class="divDotLine" style="margin-top:0.13rem; margin-bottom:0.13rem; ">
    </div>

    {{# } }}

</script>

@Helpers.OneDollarBuyingIntroduction()

@Helpers.HeaderArea(ViewBag, "headimg")

<div id="divTopTitleBar">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" style="height:100%">
        <tr style="height:0.27rem;">
            <td width="33%" align="center"><div onclick="goUrl('/Campaign/OneDollarBuying/@ViewBag.Domain.Id')">正在进行</div></td>
            <td width="33%" align="center"><div onclick="goUrl('/Campaign/OneDollarBuyingLuckyList/@ViewBag.Domain.Id')">最新揭晓</div></td>
            <td width="33%" align="center"><div onclick="goUrl('/Campaign/OneDollarBuyingParticipatedList/@ViewBag.Domain.Id')">我的参与</div></td>
        </tr>
        <tr style="height:0.03rem;">
            <td bgcolor="#E4E4E4"></td>
            <td class="defaultBgColor"></td>
            <td bgcolor="#E4E4E4"></td>
        </tr>
    </table>
</div>

<div class="divContent">

    <div id="divCommodityContainer" style="padding-left: 0.1rem; padding-right: 0.1rem;margin-top:0.2rem;">
       

    </div>

    <div id="divPagingContainer" class="divPagingContainer" style="margin-top: 0.2rem; text-align: center" onclick="loadData(_currentPage + 1)">
        查看更多
    </div>

</div>

<div id="divFooter">
    <table align="center" style="height:100%">
        <tr>
            <td valign="middle" align="center">
                <input type="button" class="button" value="玩法说明" style="width:1.5rem;" onclick="introduction()">
            </td>
        </tr>
    </table>
</div>